package com.ruoyi.module.system.controller;

import com.ruoyi.core.entity.BaseMap;
import com.ruoyi.core.entity.Output;
import com.ruoyi.web.annotations.ApiController;
import com.ruoyi.web.entity.system.MenuVo;
import com.ruoyi.web.service.SysSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@ApiController
@RestController
@RequestMapping("/sysSystem")
public class SysSystemController {

    @Autowired
    private SysSystemService sysSystemService;

    @PostMapping("/getUserMenu")
    public Output<List<MenuVo>> userMenu() {

        List<MenuVo> list = sysSystemService.getUserMenu();

        return Output.success(list);

    }

    @PostMapping("/getDictData")
    public Output<List<BaseMap>> getDictData(@RequestBody BaseMap map) {

        List<BaseMap> list = sysSystemService.getDictData(map.getString("dictType"));

        return Output.success(list);

    }

    @PostMapping("/getUserMod")
    public Output<List<BaseMap>> getUserMod() {

        List<BaseMap> list = sysSystemService.getUserMod();

        return Output.success(list);

    }

    @PostMapping("/getColumnDataSource")
    public Output<List<BaseMap>> getColumnDataSource(@RequestBody BaseMap entity) {

        List<BaseMap> list = sysSystemService.getColumnDataSource(entity.getString("columnId"));

        return Output.success(list);

    }

    @PostMapping("/getCustomDataSource")
    public Output<List<BaseMap>> getCustomDataSource(@RequestBody BaseMap entity) {

        List<BaseMap> list = sysSystemService.getCustomDataSource(entity.getString("dataSourceCode"));

        return Output.success(list);

    }
}
